Charging control method, related device, and computer storage medium

ABSTRACT

A charging device comprises a charging chip and a processor. The charging chip is configured to convert a power supply voltage into a battery voltage to charge the battery, where the power supply voltage is greater than a limiting power supply voltage, and the battery voltage is less than a limiting battery voltage. The processor is configured to: when a first condition is met, increase both the limiting power supply voltage and the limiting battery voltage, or decrease a charging current while increasing the limiting battery voltage; or when a second condition is met, decrease both the limiting power supply voltage and the limiting battery voltage, or increase the charging current while decreasing the limiting battery voltage.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a National Stage of International Application No.PCT/CN2018/107791, filed on Sep. 27, 2018, which claims priority toChinese Patent Application No. 201710927470.6, filed on Sep. 30, 2017,both of which are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the field of electronic circuittechnologies, and in particular, to a charging control method, a relateddevice, and a computer storage medium.

BACKGROUND

With continuous development of technologies such as LCD screen and dualcamera, power consumption of a terminal device is increasing. For agiven battery capacity of a device, a charging speed is particularlyimportant, and the charging speed even directly affects a user's choiceof a device or a product.

FIG. 1 is a schematic structural diagram of a battery charging circuit.As shown in FIG. 1, a charger (also referred to as an adaptor, adaptor)is connected to a USB port of a terminal device by using a universalserial bus (universal serial bus, USB), and outputs a charging voltageVsys through conversion by a charging chip (charger). The chargingvoltage can not only be used to charge a battery (battery), but can alsobe used to supply power for a system load (load). In practice, it isfound that the charging speed is affected by many factors, such as anoutput power of the charger, an impedance of a USB cable, conversionefficiency of the charging chip, dynamic power management (dynamic powermanagement, DPM, hereinafter referred to as Vdpm) of an input voltage ofthe charging chip, that is, a limiting voltage (a minimum limitingvoltage of a VBUS is shown in the figure) at a charging input end of thecharging chip, a battery internal resistance, or the like. A setting ofa charging chip Vdpm parameter is one of important parameters thataffect the charging speed.

In the prior art, to protect charging safety of a device, an initialVdpm parameter and a constant-voltage (constant-voltage, CV) protectionparameter of the battery are generally set immediately after the chargeris connected. The constant-voltage protection parameter refers to alimiting voltage at a battery power supply end of the charging chip (amaximum limiting voltage of a VBAT shown in the figure), and the twoparameters are not repeatedly set subsequently until an entire chargingprocess of the battery is completed by using the charging chip. However,Vdpm is set only once, that is, Vdpm has only one level, andconsequently, the charging speed of the battery cannot be adjustedflexibly, and charging duration is excessively long, especially when abattery voltage is relatively low, the charging speed of the foregoingsolution is relatively low, and the charging duration is increased.

SUMMARY

Embodiments of the present invention disclose a charging control method,a related device, and a computer storage medium, so that chargingduration can be shortened while charging safety of a terminal device isensured.

According to a first aspect, an embodiment of the present inventiondiscloses a terminal device, including a charging chip, a processor, anda battery. The charging chip is configured to convert a power supplyvoltage into a battery voltage to charge the battery, where the powersupply voltage is greater than a limiting power supply voltage, thebattery voltage is less than a limiting battery voltage, the limitingpower supply voltage is a minimum limiting voltage at a charging inputend of the charging chip, and the limiting battery voltage is a maximumlimiting voltage at a battery power supply end of the charging chip. Theprocessor is configured to: when a first condition is met, increase boththe limiting power supply voltage and the limiting battery voltage, ordecrease a charging current while increasing the limiting batteryvoltage; or when a second condition is met, decrease both the limitingpower supply voltage and the limiting battery voltage, or increase thecharging current while decreasing the limiting battery voltage. Thecharging current is a current used to charge the battery, the firstcondition includes at least that the battery voltage is greater than abattery voltage threshold, and the second condition includes at leastthat the battery voltage is less than the battery voltage threshold.

In this application, to implement charging of the terminal device, acharging circuit is disposed in the terminal device, where the chargingcircuit includes but is not limited to a switching charging circuit anda linear charging circuit. The charging circuit includes a chargingchip, a processor, and a battery, and optionally, may further includeother components, such as a load and a peripheral device. To shorten thecharging duration of the terminal device, when the charger is connectedto the terminal device for charging, related parameters in the chargingcircuit may be adjusted in this embodiment of this application. Forexample, in the switching charging circuit, both the limiting powersupply voltage Vdpm and the limiting battery voltage (that is, aconstant voltage protection parameter) are adjusted based on the batteryvoltage. In the linear charging circuit, the limiting battery voltage isadjusted, or both the limiting battery voltage and a charging current inthe charging circuit are adjusted based on the battery voltage.

By implementing this embodiment of the present invention, the chargingduration of the terminal device can be shortened while charging safetyof the terminal device is ensured.

In some possible embodiments, when the charging circuit is the switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are increased, the firstcondition further includes that a test voltage is less than a presetthreshold, and/or a target quantity of times exceeds a preset quantityof times. Alternatively, when the charging circuit is the switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are decreased, the secondcondition further includes that a test voltage is less than a presetthreshold, and/or a target quantity of times exceeds a preset quantityof times.

The test voltage refers to a voltage at a charging input end (VBUS) ofthe charging chip in a charging process of the terminal device. Thevoltage may be an actual voltage at the charging input end when theterminal device is normally charged, or may refer to a voltage detectedwhen a test current is used to test the charging input end. This is notlimited in the present invention. Generally, after preset duration, thevoltage at the charging input end may be collected for use as the testvoltage, to ensure accuracy of test voltage data.

The target quantity of times is a quantity of times that the testvoltage is less than the preset threshold. To avoid a misjudgment andensure accuracy of parameter adjustment, the terminal device may obtain,for a plurality of times, whether the test voltage is less than thepreset threshold. When the quantity of times that the test voltage isless than the preset threshold exceeds the preset quantity of times, itis determined that the related parameters in the charging circuit needto be adjusted. For example, if a quantity of times that the testvoltage is less than the preset threshold is at least two in three testvoltage judgments, the related parameters in the charging circuit needto be adjusted.

In some possible embodiments, when the charging circuit is the switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are increased, the firstcondition further includes that the battery voltage is in a risingperiod.

In some possible embodiments, when the charging circuit is the switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are decreased, the secondcondition further includes that the battery voltage is in the risingperiod, or the battery voltage is in a dropping period.

To ensure the accuracy of parameter adjustment, a change trend of thebattery voltage may be added to adjust the related parameters in thecharging circuit. During specific implementation, the charging chip maycollect and record, in real time or periodically, the voltage at thebattery power supply end (that is, the battery voltage in thisapplication), and store the voltage. Correspondingly, the processor mayanalyze the change trend of the battery voltage based on a recordedbattery voltage in the preset duration, for example, in the risingperiod or the dropping period.

In some possible embodiments, when the second condition further includesthat the battery voltage is in the rising period, the battery voltagethreshold is a first battery voltage threshold; or when the secondcondition further includes that the battery voltage is in the droppingperiod, the battery voltage threshold is a second battery voltagethreshold. The first battery voltage threshold is greater than thesecond battery voltage threshold.

According to a second aspect, an embodiment of the present inventiondiscloses a charging control method, to control charging of a terminaldevice, where the terminal device includes a charging chip, a processor,and a battery, and the method includes:

converting, by the charging chip, a power supply voltage into a batteryvoltage to charge the battery, where the power supply voltage is greaterthan a limiting power supply voltage, the battery voltage is less than alimiting battery voltage, the limiting power supply voltage is a minimumlimiting voltage at a charging input end of the charging chip, and thelimiting battery voltage is a maximum limiting voltage at a batterypower supply end of the charging chip; and

when a first condition is met, increasing, by the processor, both thelimiting power supply voltage and the limiting battery voltage, ordecreasing a charging current while increasing the limiting batteryvoltage; or when a second condition is met, decreasing, by theprocessor, both the limiting power supply voltage and the limitingbattery voltage, or increasing the charging current while decreasing thelimiting battery voltage, where the charging current is a current usedto charge the battery, the first condition includes at least that thebattery voltage is greater than a battery voltage threshold, and thesecond condition includes at least that the battery voltage is less thana battery voltage threshold.

For content that is not described or not shown in this embodiment of thepresent invention, refer to related descriptions in the foregoingembodiment of the first aspect. Details are not described herein again.

According to a third aspect, an embodiment of the present inventiondiscloses a terminal device, including a charging chip and a battery.

The charging chip is configured to convert a power supply voltage into abattery voltage to charge the battery, where the power supply voltage isgreater than a limiting power supply voltage, the battery voltage isless than a limiting battery voltage, the limiting power supply voltageis a minimum limiting voltage at a charging input end of the chargingchip, and the limiting battery voltage is a maximum limiting voltage ata battery power supply end of the charging chip.

The charging chip is configured to: when a first condition is met,increase both the limiting power supply voltage and the limiting batteryvoltage, or decrease a charging current while increasing the limitingbattery voltage; or when a second condition is met, decrease both thelimiting power supply voltage and the limiting battery voltage, orincrease the charging current while decreasing the limiting batteryvoltage, where the charging current is a current used to charge thebattery, the first condition includes at least that the battery voltageis greater than a battery voltage threshold, and the second conditionincludes at least that the battery voltage is less than the batteryvoltage threshold.

For content that is not described or not shown in this embodiment of thepresent invention, refer to related descriptions in the foregoingembodiment of the first aspect. Details are not described herein again.

According to a fourth aspect, an embodiment of the present inventiondiscloses a charging chip, including a processor and one or moreinterfaces coupled to the processor.

The processor is configured to convert a power supply voltage into abattery voltage to charge the battery, where the power supply voltage isgreater than a limiting power supply voltage, the battery voltage isless than a limiting battery voltage, the limiting power supply voltageis a minimum limiting voltage at a charging input end of the chargingchip, and the limiting battery voltage is a maximum limiting voltage ata battery power supply end of the charging chip.

The processor is further configured to: when a first condition is met,increase both the limiting power supply voltage and the limiting batteryvoltage, or decrease a charging current while increasing the limitingbattery voltage; or when a second condition is met, decrease both thelimiting power supply voltage and the limiting battery voltage, orincrease the charging current while decreasing the limiting batteryvoltage, where the charging current is a current used to charge thebattery, the first condition includes at least that the battery voltageis greater than a battery voltage threshold, and the second conditionincludes at least that the battery voltage is less than the batteryvoltage threshold.

According to a fifth aspect, an embodiment of the present inventionprovides a terminal device, including a memory, a communicationsinterface, and a processor coupled to the memory and the communicationsinterface. The memory is configured to store an instruction. Theprocessor is configured to execute the instruction. The communicationsinterface is configured to communicate with a terminal device undercontrol of the processor. When executing the instruction, the processorperforms the method described in the second aspect.

According to a sixth aspect, a computer readable storage medium isprovided, where the computer readable storage medium stores program codeused for mail transmission, and the program code includes an instructionused to perform the method described in the second aspect.

According to a seventh aspect, a computer program product including aninstruction is provided. When the instruction is run on a computer, thecomputer is enabled to perform the method described in the secondaspect.

By implementing this embodiment of the present invention, the chargingduration can be shortened while charging safety of the device isensured.

BRIEF DESCRIPTION OF DRAWINGS

To describe technical solutions in the embodiments of the presentinvention or in the prior art more clearly, the following brieflydescribes accompanying drawings required for describing the embodimentsor the prior art.

FIG. 1 is a schematic diagram of a charging circuit according to theprior art;

FIG. 2A is a schematic structural diagram of a terminal device accordingto an embodiment of the present invention;

FIG. 2B is a schematic structural diagram of still another terminaldevice according to an embodiment of the present invention;

FIG. 3 is a schematic diagram of a switching charging circuit accordingto an embodiment of the present invention;

FIG. 4 is a schematic structural diagram of still another terminaldevice according to an embodiment of the present invention;

FIG. 5 is a schematic diagram of a linear charging circuit according toan embodiment of the present invention;

FIG. 6 is a schematic structural diagram of still another terminaldevice according to an embodiment of the present invention;

FIG. 7 is a schematic flowchart of a charging control method accordingto an embodiment of the present invention;

FIG. 8A is a schematic structural diagram of still another terminaldevice according to an embodiment of the present invention;

FIG. 8B is a schematic structural diagram of still another terminaldevice according to an embodiment of the present invention; and

FIG. 9 is a schematic structural diagram of an apparatus according to anembodiment of the present invention.

DESCRIPTION OF EMBODIMENTS

The following describes technical solutions in the embodiments of thepresent invention in detail with reference to accompanying drawings inthe present invention.

In a process of proposing this application, an inventor of thisapplication finds that charging of a terminal device is generallydivided into four phases: trickle-charge (trickle-charge), pre-charge(pre-charge), constant-current charge (constant-current charge, CC), andconstant-voltage charge (constant-voltage charge, CV). Theconstant-current charge CC is one of phases that mainly affect acharging speed. Generally, designers expect that a time that a terminaldevice stays in the CC phase is long enough, so that a current is highenough, to correspondingly reduce charging duration.

In a charging solution of an existing terminal device shown in FIG. 1,when a charger is connected for charging, a charging chip may convert aninput power supply voltage into a charging voltage Vsys, and thenconvert and output a corresponding battery voltage by using a component(such as a switching transistor) at a battery supply end VBAT, where thebattery voltage is used to charge a battery. To protect charging safetyof the device, a constant voltage protection parameter and a Vdpmparameter are set for the charging chip immediately after the charger isconnected. When the battery voltage reaches the constant voltageprotection parameter, the battery enters a phase of the constant-voltagecharge CV, to protect safety of a rechargeable battery. In the priorart, there are specifically the following two implementation solutionsfor setting the constant voltage protection parameter and Vdpmparameter.

In a first solution, an initial constant voltage protection parameterand an initial Vdpm parameter are set after the charger is connected,and the two parameters are no longer set in an entire subsequentcharging process of the device. Consequently, a battery charging speedcannot be flexibly adjusted, and the charging duration is relativelylong, especially when a battery voltage of the device is relatively low.

In a second solution, the initial constant voltage protection parameterand Vdpm parameter may be set after the charger is connected, and Vdpmparameter may be dynamically adjusted based on the battery voltage in acharging cycle, and the constant voltage protection parameter remainsunchanged. The battery voltage is an actual voltage of the battery. Asshown in FIG. 1, the battery voltage is an actual voltage of the VBAT.However, in practice, it is found that when Vdpm parameter is set to berelatively low (that is, Vdpm parameter is in a low level), if Vdpmparameter fails to be updated due to a system breakdown or anotherfault, that is, Vdpm parameter cannot be set to a high level.Consequently, a buck transistor buck inside the charging chip may bepunched through, and the charging chip may be damaged; and even aregister of the charging chip may be overwritten, the battery voltagemay exceed the constant voltage protection parameter, and potentialsafety hazards such as a battery explosion during charging may occur.

To resolve the foregoing problems, refer to FIG. 2A. FIG. 2A is aschematic architecture diagram of a terminal device according to anembodiment of the present invention. The terminal device 100 shown inFIG. 2A includes a charging circuit used for device charging, where thecharging circuit may include a charging chip 102, a processor 104, and abattery 106. The charging chip 102 is configured to convert a powersupply voltage into a battery voltage to charge the battery 106, wherethe power supply voltage is greater than a limiting power supplyvoltage, and the battery voltage is less than a limiting batteryvoltage. The processor 104 is configured to: when a first condition ismet, increase both the limiting power supply voltage and the limitingbattery voltage, or decrease a charging current while increasing thelimiting battery voltage, where the first condition includes at leastthat the battery voltage is greater than a battery voltage threshold.The processor 104 is further configured to: when a second condition ismet, decrease both the limiting power supply voltage and the limitingbattery voltage, or increase the charging current while decreasing thelimiting battery voltage, where the second condition includes at leastthat the battery voltage is less than the battery voltage threshold.

In this application, the limiting power supply voltage is a minimumlimiting voltage at a charging input end of the charging chip.Specifically, the limiting power supply voltage may be an allowableminimum limiting voltage set by the charging input end, that is, theforegoing Vdpm, for example, a minimum limiting voltage Vdpm parameterof the VBUS end shown in FIG. 1. The limiting battery voltage is amaximum limiting voltage at the battery power supply end of the chargingchip, and may be specifically an allowable maximum limiting voltage setby the battery power supply end, that is, the foregoing constant voltageprotection parameter, for example, a maximum limiting voltage parameterof the VBAT end shown in FIG. 1. The power supply voltage refers to anactual voltage at the charging input end of the charging chip, forexample, an actual voltage at a VBUS end shown in FIG. 1. The batteryvoltage refers to an actual voltage at the battery power supply end ofthe charging chip, for example, an actual voltage at a VBAT end shown inFIG. 1.

In an optional embodiment, the charging circuit includes but is notlimited to a switching charging circuit and a linear charging circuit.In different charging circuits, the processor 104 may compare thebattery voltage with the battery voltage threshold, and thencorrespondingly adjust a corresponding charging parameter. The batteryvoltage threshold may be independently set on a user side or a terminaldevice side, and this is not limited in the present invention.

For example, in the switching charging circuit, when the battery voltageis greater than the battery voltage threshold, both the limiting powersupply voltage (Vdpm) and the limiting battery voltage may be increased.In the linear charging circuit, when the battery voltage is greater thanthe battery voltage threshold, the limiting power supply voltage (thatis, the constant voltage protection parameter) may be increased, or thecharging current may be decreased while the limiting power supplyvoltage is increased. The charging current refers to a magnitude of acurrent that is used for charging the battery 106 and that is output bythe battery power supply end of the charging chip. Correspondingly, inthe switching charging circuit, when the battery voltage is less thanthe battery voltage threshold, both the limiting power supply voltage(Vdpm) and the limiting battery voltage may be decreased. In the linearcharging circuit, when the battery voltage is less than the batteryvoltage threshold, the limiting battery voltage may be decreased, or thecharging current may be increased while the limiting battery voltage isdecreased. The following describes in detail how to adjust relatedparameters in the charging circuit.

It should be understood that, in a charging process of the terminaldevice, after the charger is connected, an impedance (resistance) existsbetween an output port of the charger and the charging input end of thecharging chip. It is assumed that an input voltage of the charger is V0,the limiting power supply voltage set at the charging input end (as theVBUS shown in FIG. 1) of the charging chip is Vdpm, and an impedance ofa charging link is R (as an impedance between an adaptor and the VBUSend shown in FIG. 1). Correspondingly, it can be learned from Ohm's lawI=(V0−Vdpm)/R that, for a given R, I is proportional to a voltagedifference (V0−Vdpm) on a charging cable. When die battery voltage isless than the battery voltage threshold (to be specific, a residualbattery capacity is less than a preset capacity value), the chargingcurrent should be increased, to be specific, Vdpm should be decreased,to shorten the charging duration. Correspondingly, when the batteryvoltage (a battery capacity) is greater than the battery voltagethreshold, the charging current should be decreased, to be specific,Vdpm should be increased to protect charging safety of the devicebattery.

By implementing this embodiment of the present invention, the followingproblems with the prior art can be avoided: The charging speed of adevice cannot be flexibly adjusted, and the charging duration isexcessively long because Vdpm and the constant voltage protectionparameter are set once; the charging chip is damaged or the batteryexplodes during charging because Vdpm is not updated in time, and thelike.

It should be noted that, in actual application, the charging chip 102 inthe terminal device shown in FIG. 2A may include a processor, and theprocessor of the charging chip 102 and the processor 104 may be a samephysical processor, to be specific, the processor 104 may also bedisposed on the charging chip 102. For details, refer to FIG. 2B, whichis a schematic architectural diagram of another possible terminaldevice.

As shown in FIG. 2B, the terminal device 200 includes a charging circuitused for device charging, and the charging circuit may include acharging chip 202 and a battery 206.

The charging chip 202 is configured to convert a power supply voltageinto a battery voltage to charge the battery 206, where the power supplyvoltage is greater than a limiting power supply voltage, and the batteryvoltage is less than a limiting battery voltage.

The charging chip 202 is further configured to: when a first conditionis met, increase both the limiting power supply voltage and the limitingbattery voltage, or decrease both a charging current while increasingthe limiting battery voltage, where the first condition includes atleast that the battery voltage is greater than a battery voltagethreshold.

The charging chip 202 is further configured to: when a second conditionis met, decrease both the limiting power supply voltage and the limitingbattery voltage, or increase a charging current while decreasing thelimiting battery voltage, where the second condition includes at leastthat the battery voltage is less than the battery voltage threshold.

For a part that is not shown or not described in this embodiment of thepresent invention, refer to related descriptions in the foregoingembodiment in FIG. 2A. Details are not described herein again.

In the following embodiments of the present invention, the terminaldevice shown in FIG. 2A is used as an example to describe in detail twocharging circuits and the charging control embodiments of the terminaldevice corresponding to the two charging circuits used in the presentinvention. FIG. 3 and FIG. 4 show related embodiments of the switchingcharging circuit according to the present invention. FIG. 5 and FIG. 6show related embodiments of the linear charging circuit according to thepresent invention.

FIG. 3 is a schematic diagram of the switching charging circuit. Theswitching charging circuit 300 may include a charging chip 302, aprocessor 304, and a battery 306. The charging chip 302 is electricallyconnected to both the processor 304 and the battery 306.

In an optional embodiment, the charging chip may include a charginginput end VBUS and a battery power supply end VBAT. The charging inputend may be externally connected to a power supply (such as an externalcharger), to input a power supply voltage. The battery power supply endis electrically connected to the battery 306, to output a chargingcurrent or a charging voltage to charge the battery.

In an optional embodiment, the processor may be electrically connectedto the charging chip by using an inter-integrated circuit(inter-integrated circuit, I2C) bus. The I2C bus may include a systemclock line (system clock line, SCL) and a serial data line (serial data,SDA). Details are not described in this application.

In an optional embodiment, the switching charging circuit may furtherinclude a load (load), and the charging chip is electrically connectedto the load. Optionally, the switching charging circuit may furtherinclude a peripheral device. For example, in FIG. 3, the charging chipmay further include a capacitor C and an inductor L. The charging chipmay further include a first port, a second port, and a third port, andcorresponding ports are LX port, BST port, and SYS port in the figure.The LX port is electrically connected to the load by using the inductor.The BST port is electrically connected to the LX port and one end of theinductor by using the capacitor. The SYS port is electrically connectedto the load.

In an optional embodiment, the switching charging circuit furtherincludes an overvoltage protection (overvoltage protection, OVP) chip,primary and secondary board connection interfaces, and a charginginterface. The OVP chip is configured to protect the charging chip, andcontrol an actual voltage at a charging input end of the charging chipto not exceed a chip upper limit threshold. The chip upper limitthreshold may be independently set on a user side or a terminal deviceside, and this is not described in much detail in the present invention.The primary and secondary board connection interfaces are configured toelectrically connect a primary board and a secondary board, and theprimary board may include but is not limited to the charging chip 302,the processor 304, the battery 306, and components of subsequentoptional embodiments such as a load, an OVP chip, and a connectioninterface of the primary board. The secondary board may include but isnot limited to a connection interface of the secondary board and acharging interface, as specifically shown in FIG. 3. The primary andsecondary board connection interfaces may be connected by using aflexible printed circuit (flexible printed circuit, FPC). The charginginterface is configured to externally connect a charging power supply toinput a power supply voltage to the charging chip, where the charginginterface includes but is not limited to a universal serial bus(universal serial bus, USB) interface.

In an optional embodiment, when the switching charging circuit is usedfor charging, the charging interface may be externally connected to acharger or an adaptor, as specifically shown in FIG. 3. Relatedcomponents used in the present invention are not described much detailin this application.

Based on the schematic diagram of the switching charging circuit shownin FIG. 3, FIG. 4 is a schematic structural diagram of a terminal deviceaccording to an embodiment of the present invention. The terminal devicemay include all or some of connected components of the switchingcharging circuit in the embodiment shown in FIG. 3. This is not limitedin the present invention. FIG. 4 only shows that the terminal deviceincludes a charging chip 302, a processor 304, and a battery 306. Thefollowing describes specific embodiments related to these components.

The charging chip 302 is configured to convert a power supply voltageinto a battery voltage to charge the battery 306, where the power supplyvoltage is greater than a limiting power supply voltage, and the batteryvoltage is less than a limiting battery voltage.

The processor 304 is configured to: when a first condition is met,increase both the limiting power supply voltage and the limiting batteryvoltage, where the first condition includes at least that the batteryvoltage is greater than a battery voltage threshold.

The processor 304 is further configured to: when a second condition ismet, decrease both the limiting power supply voltage and the limitingbattery voltage, where the second condition includes at least that thebattery voltage is less than the battery voltage threshold.

The following describes some specific embodiments and optionalembodiments used in the present invention.

After the charger is connected to the terminal device for charging, theprocessor 304 may determine whether the first condition is met. If thefirst condition is met, the processor 304 may increase both the limitingpower supply voltage (Vdpm) and the limiting battery voltage (that is, aconstant voltage protection parameter). The first condition may includethat the battery voltage is greater than the battery voltage threshold.For the battery voltage, the battery voltage threshold, the limitingpower supply voltage, and the limiting battery voltage, refer to relateddescriptions in the foregoing embodiments. Details are not describedherein again.

During specific implementation, the processor 304 may send a firstacquisition instruction to the charging chip 302, where the firstacquisition instruction is used to obtain a voltage at the battery powersupply end (VBAT) of the charging chip, that is, a battery voltage inthis application. Correspondingly, the charging chip 302 may receive thefirst acquisition instruction, collect a voltage (that is, the batteryvoltage) at the battery power supply end based on the first acquisitioninstruction, and feed back the voltage at the battery power supply endto the processor 304. Then, the processor 304 may adjust relatedparameters in the charging circuit based on the obtained batteryvoltage. For example, when the processor 304 determines that the batteryvoltage is greater than or equal to the battery voltage threshold (forexample, 4.08 V), both the limiting power supply voltage (Vdpm) and thelimiting battery voltage may be increased. If the processor 304determines that the battery voltage is less than the battery voltagethreshold (for example, 4.08 V), both the limiting power supply voltage(Vdpm) and the limiting battery voltage may be decreased.

In an optional embodiment, the first condition or the second conditionmay further include that a test voltage is less than a preset threshold,and/or a target quantity of times exceeds a preset quantity of times.The test voltage may refer to a voltage at the charging input end thatis actually detected after the charger is connected to the terminaldevice, or a voltage at the charging input end that is detected by thecharging chip by using a test current. The target quantity of times is aquantity of times that the test voltage is less than a preset threshold.The preset threshold and the preset quantity of times may beindependently set on the user side or the terminal device side.Optionally, the preset threshold may be a default limiting powerthreshold set by the system, such as 4.675 V, or a threshold customizedby another user/system, and this is not limited in the presentinvention. The following describes two implementations used duringspecific implementation.

In a first implementation, before the processor 304 sends the firstacquisition instruction to the charging chip 302, the processor 304 maysend a read instruction to the charging chip 302, where the readinstruction is used to read whether the charging chip is in a DPM state,and the DPM state is configured to indicate that the test voltage isless than or equal to the preset threshold. Optionally, the DPM statemay be configured to indicate that the test voltage triggers the presetthreshold, and the test voltage is less than or remains at the presetthreshold.

Correspondingly, the charging chip may receive the read instruction, andfeeds back the state of the charging chip to the processor based on aninstruction of the read instruction. The state of the charging chipincludes being in the DPM state or not being in the DPM state. The statemay be preset by the charging chip. Details are described below When theprocessor 304 determines that the charging chip is in the DPM state (tobe specific, the test voltage is less than or equal to the presetthreshold), the processor 304 may continue to send the first acquisitioninstruction to the charging chip 302, to adjust both the limiting powersupply voltage Vdpm and the limiting battery voltage (that is, theconstant voltage protection parameter) based on the obtained batteryvoltage.

In an optional embodiment, a state of the charging chip may beidentified by using a preset character string. The preset characterstring includes but is not limited to preset letters, preset numbers,and the like. For example, “0” may be used to indicate that the chargingchip is not in the DPM state, and “1” may be used to indicate that thecharging chip is in the DPM state.

In an optional embodiment, the state of the charging chip may be presetby the charging chip. In one specific implementation, to ensure datareliability, after the charger is connected to the terminal device, thecharging chip may collect, after a first preset duration, the voltage atthe charging input end (VBUS) for use as the test voltage. When the testvoltage is less than or equal to a preset threshold, the charging chipmay mark that the charging chip is in the DPM state, for example, mark astate of the charging chip as “1”. Correspondingly, when the testvoltage is greater than the preset threshold, the charging chip may markthat the charging chip is not in the DPM state, for example, mark thestate of the charging chip as “0”.

In another specific implementation, after the charger is connected tothe terminal device, the charging chip may record a magnitude of acurrent on a serial data line, and the current is used as a firstcurrent. The serial data line is a cable connected to the charger andthe charging chip (that is, the terminal device), and may also bereferred to as a charging cable. Because specifications of chargingcables produced by different manufacturers are different (that is,impedances of the charging cables are different), the charging chip maydetect a voltage at a charging input end of the charging chip by using atest current, and the voltage is used as the test voltage. Specifically,the charging chip may set a current on the charging cable to be a testcurrent (for example, 900 mA, mA), and collect, after a second presetduration, the voltage at the charging input end for use as the testvoltage. Then, when it is determined that the test voltage is less thanor equal to a preset threshold, the charging chip marks that thecharging chip is in the DPM state. Correspondingly, when it isdetermined that the test voltage is greater than the preset threshold,the charging chip marks that the charging chip is not in the DPM state.

In an optional embodiment, the test current and the second presetduration may be independently set on a user side or a terminal deviceside. This is not limited in the present invention. After the chargingchip marks whether the charging chip is in the DPM state, the chargingchip may reset a current of the charging cable to the first current,where the first current is a current of the charging cable when thecharger is connected to the terminal device for normal charging.

In an optional embodiment, to ensure accuracy of parameter adjustmentand high reliability of device charging control, the processor 304 mayobtain the state of the charging chip for a plurality of times. If aquantity of times of the charging chip that is in the DPM state exceedsa preset quantity of times (that is, a quantity of times that the testvoltage is less than a preset threshold), the processor 304 may continueto perform a subsequent procedure to send a first acquisitioninstruction to the charging chip 302, to adjust related parameters inthe charging circuit based on the obtained battery voltage, for example,both the limiting power supply voltage Vdpm and the limiting batteryvoltage.

In an optional embodiment, when the processor 304 determines that thecharging chip is in the DPM state or the quantity of times of thecharging chip that is in the DPM state exceeds a preset quantity oftimes, the processor 304 may determine that the terminal device iscurrently in a weak charging state, where the weak charging state isassociated with the DPM state or the quantity of times of the DPM state.Correspondingly, the processor 304 may continue to perform thesubsequent procedure to adjust the related parameters in the chargingcircuit based on the obtained battery voltage, for example, the limitingpower supply voltage Vdpm and the limiting battery voltage. On thecontrary, when the processor 304 determines that the charging chip isnot in the DPM state, or the quantity of times of the charging chip thatis in the DPM state does not exceed the preset quantity of times, theprocessor 304 may determine that the terminal device is currently in anon-weak charging state, and may end the subsequent procedure.

In a second implementation, before the processor 304 sends a firstacquisition instruction to the charging chip 302, the processor 304 maydirectly send a second acquisition instruction to the charging chip 302,where the second acquisition instruction is used to obtain a testvoltage at a charging input end of the charging chip. Correspondingly,after receiving the second acquisition instruction, the charging chipcollects the test voltage at the charging input end based on aninstruction of the second acquisition instruction, and feeds back thetest voltage to the processor 304. Further, the processor 304 maycompare the obtained test voltage with a preset threshold, and when thetest voltage is less than or equal to the preset threshold, may send thefirst acquisition instruction to the charging chip 302, to adjustrelated parameters based on an obtained battery voltage. When the testvoltage is greater than the preset threshold, a procedure may be ended.The following describes two specific implementations for obtaining thetest voltage.

In one specific implementation, the processor 304 sends a secondacquisition instruction to the charging chip 302. Correspondingly, thecharging chip 302 receives the second acquisition instruction, andobtains a voltage at the charging input end (VBUS) based on theinstruction of the second acquisition instruction for use as the testvoltage.

In another specific implementation, the processor 304 sends a secondacquisition instruction to the charging chip 302. Correspondingly, thecharging chip 302 receives the second acquisition instruction, and thecharging chip may record a magnitude of a current on the serial dataline, and the current is used as a first current. Next, the chargingchip 302 may use a voltage at a charging input end of the charging chipthat is detected by the test current as the test voltage. For details,refer to related descriptions in the foregoing first implementation.Details are not described herein again.

In an optional embodiment, the processor 304 may further determine animpedance on the serial data line. Specifically, the processor 304 maydetermine an impedance R1 on the serial data line based on a targetpressure difference V1 and a current I on the serial data line. V1=I*R1,where V1, I, and R1 are all positive numbers. The target voltagedifference V1 is a difference between an output voltage Vout of thecharger and the test voltage Vin.

In an optional embodiment, to ensure accuracy of parameter adjustmentand high reliability of device charging control, the processor 304 mayobtain a test voltage at a charging input end of the charging chip for aplurality of times. When a quantity of times that the test voltage isless than or equal to a preset threshold (that is, a target quantity oftimes) exceeds a preset quantity of times, the processor 304 maycontinue to perform a subsequent procedure. Details are not describedherein again. On the contrary, when the quantity of times that the testvoltage is less than or equal to the preset threshold does not exceedthe preset quantity of times, procedures may be ended, and the relatedparameters (for example, Vdpm and a constant voltage protectionparameter) in the charging circuit are not adjusted.

In an optional embodiment, when the processor 304 determines that thetest voltage is less than or equal to a preset threshold, or thequantity of times that the test voltage is less than or equal to thepreset threshold exceeds a preset quantity of times, the processor 304may determine that the terminal device is in a weak charging state, andfurther, may continue to adjust the related parameters in the chargingcircuit based on the obtained battery voltage. Details are not describedherein again. On the contrary, when the processor 304 determines thatthe test voltage is less than or equal to the preset threshold, or thequantity of times that the test voltage is less than or equal to thepreset threshold does not exceed the preset quantity of times, theprocessor 304 may determine that the terminal device is in a non-weakcharging state, procedures may be ended, and the related parameters inthe charging circuit are not adjusted.

In an optional embodiment, the first condition may further include thatthe battery voltage is in a rising period. Optionally, the secondcondition may further include that the battery voltage is in the risingperiod or the battery voltage is in a dropping period.

During specific implementation, the charging chip 302 may record, inreal time or periodically, a voltage at the battery power supply end(VBAT), that is, the battery voltage in this application. A recordingform of the battery voltage is not limited in the present invention, forexample, stored in a form such as a data table, a vector, or a matrix.The processor 304 may obtain the battery voltage recorded in a thirdpreset duration, and analyze these battery voltages, to determinewhether the battery voltage in the third preset duration is in therising period or the dropping period. For example, if the batteryvoltage recorded in the third preset duration gradually increases withtime, it indicates that the battery voltage is in the rising period; orif the battery voltage recorded in the third preset duration graduallydecreases with time, it indicates that the battery voltage is in thedropping period. The third preset duration may be independently set on auser side or a terminal device side, and this is not limited in thepresent invention.

Correspondingly, the processor 304 may adjust both the limiting powersupply voltage (Vdpm) and the limiting battery voltage based on theobtained battery voltage. Specifically, when it is determined that thebattery voltage is in the rising period and the battery voltage isgreater than a battery voltage threshold (that is, a first condition ismet), the processor 304 may increase both the limiting power supplyvoltage (Vdpm) and the limiting battery voltage. Correspondingly, whenit is determined that the battery voltage is less than the batteryvoltage threshold, regardless of whether the battery voltage is in therising period or the dropping period (that is, a second condition ismet), the processor 304 may decrease both the limiting power supplyvoltage Vdpm and the limiting battery voltage.

In an optional embodiment, when the second condition further includesthat the battery voltage is in the rising period, the battery voltagethreshold is a first battery voltage threshold; or when the secondcondition further includes that the battery voltage is in the droppingperiod, the battery voltage threshold is a second battery voltagethreshold, where the first battery voltage threshold is greater than thesecond battery voltage threshold.

To ensure stability of parameter adjustment, a voltage hysteresisinterval can be set. Specifically, the processor 304 may obtain abattery voltage within the third preset duration. If the processorlearns, through analysis, that the battery voltage is in the risingperiod, and the battery voltage is less than or equal to the firstbattery voltage threshold, both the limiting power supply voltage Vdpmand the limiting battery voltage may be decreased. Correspondingly, ifthe processor learns, by analyzing, that the battery voltage is in thedropping period, the voltage hysteresis interval may be set, to bespecific, the battery voltage is less than or equal to the secondbattery voltage threshold, both the limiting power supply voltage Vdpmand the limiting battery voltage may be decreased. The first batteryvoltage threshold is greater than the second battery voltage threshold,and the voltage hysteresis interval is from the first battery voltagethreshold to the second battery voltage threshold.

A battery of 4.4 V and a charger of 5 V (that is, the charger isconnected to a charging power supply of 5 V) are used as an example.After the charger is connected to the terminal device to charge thebattery, the charging chip 302 may record a first current on a chargingcable, where the charging cable is a serial data line used to connectthe charger to the terminal device. Further, the charging chip maydetect a voltage at the charging input end of the charging chip on thecharging cable by using a test current, and after the first presetduration (for example, a latency of 100 ms), collect a voltage at thecharging input end for use as the test voltage. When it is determinedthat the test voltage is less than or equal to a preset threshold (4.675V is used as an example), the charging chip may mark that the chargingchip is in a DPM state (or a weak charging state); otherwise, thecharging chip marks that the charging chip is not in the DPM state.Correspondingly, the charging chip may further reset the current on thecharging cable to the first current, to restore normal charging of theterminal device.

Correspondingly, the processor 304 may send a read instruction to thecharging chip to read whether the charging chip is in the DPM state.After the processor 304 determines, through reading, that the chargingchip is not in the DPM state, it may be determined that the terminaldevice is currently in a non-weak charging state, and a procedure isended. After the processor 304 determines, through reading, that thecharging chip is in the DPM state, it may be determined that theterminal device is currently in the weak charging state; and then theprocessor 304 may obtain a voltage at a battery power supply end of thecharging chip, that is, the battery voltage in this application.

Next, the processor may adjust both the limiting power supply voltage(Vdpm) and the limiting battery voltage (that is, the constant voltageprotection parameter) based on the battery voltage. For details aboutVdpm and the constant voltage protection parameter, refer to relateddescriptions in the foregoing embodiment. Details are not describedherein again. For example, when the battery voltage is in the risingperiod and the battery voltage is greater than the first battery voltagethreshold (for example, 4.08 V), the processor may adjust the limitingpower supply voltage (Vdpm) to a high level (for example, 4.675 V) andthe limiting battery voltage to a 4.4 V, or the like. When the batteryvoltage is in the rising period and the battery voltage is less than orequal to the first battery voltage threshold 4.08 V, the processor mayadjust the limiting power supply voltage (Vdpm) to a low level (forexample, 4.46 V) and the limiting battery voltage to 4.15 V, or thelike. When the battery voltage is in the dropping period, the voltagehysteresis interval (for example, 280 mV millivolt) may be set, to bespecific, the battery voltage is less than or equal to the secondbattery voltage threshold (4.08 V−0.28 V=3.8 V), the processor mayadjust the limiting power supply voltage (Vdpm) to a low level (forexample, 4.46 V) and the limiting battery voltage to 4.15 V, or thelike.

It should be understood that, in an initial charging phase of theterminal device, to be specific, the battery voltage is less than orequal to the first battery voltage threshold, to shorten chargingduration, a charging current should be increased. Refer to relateddescriptions in the foregoing embodiment described in FIG. 2A. I=(V0 toVdpm)/R, where V0 is a charging power source 5 V, and R is an impedanceof a charging cable. For a given impedance of the charging cable, toincrease the charging current I, Vdpm should be decreased.Correspondingly, when a battery capacity exceeds a specified threshold,to be specific, when the battery voltage is greater than the firstbattery voltage threshold, to ensure charging safety of a battery, acharging current should be decreased. Referring to the foregoingdescription, for the given impedance on the charging cable, to reducethe charging current I, Vdpm should be increased.

In an optional embodiment, when the charger is connected to the terminaldevice for charging, the processor 304 may further record chargingduration of the terminal device, so that a user can view the chargingduration of the device, and intuitively understand that the chargingduration of the terminal device can be shortened after this applicationis used. Table 1 provides an example of a test data table. The test datatable intuitively reflects that the charging duration of the terminaldevice after use of this application is definitely less than chargingduration of the terminal device in a conventional technology.

TABLE 1 Charging duration Charging duration Actual total detected whendetected when Test Sample impedance of this application this applicationYield Average condition number a cable (ohm) is not used is used timeyield time 0.75 ohm 1 0.954 5 h 59 min 4 h 50 min 1 h 09 min 70 minconnected 2 0.908 5 h 43 min 4 h 30 min 1 h 13 min in series to 3 0.98 6h 03 min 4 h 55 min 1 h 08 min a standard serial data line 0.5 ohm 40.693 4 h 12 min 3 h 33 min 39 min 30 min connected 5 0.729 3 h 44 min 3h 20 min 24 min in series to 6 0.954 5 h 59 min 4 h 50 min 1 h 09 mm astandard serial data line

It may be learned from Table 1 that the foregoing standard serial dataline refers to a data cable used to connect the charger to the terminaldevice, that is, the foregoing charging cable. Impedances of standardserial data lines produced by different manufacturers are different,that is, impedances of some serial data lines are relatively low, andimpedances of some serial data lines are relatively high. Therefore, inthe test procedure, to ensure accuracy of test data, an impedance of anappropriate size (for example, the impedance of 0.75 ohms or 0.5 ohmsshown in Table 1) can be connected in series to the standard serial dataline, and a plurality of serial data lines are used for test under asame test condition. It can be intuitively learned from Table 1 that thecharging duration may be significantly shortened by correspondinglyadjusting related parameters (for example, the limiting power supplyvoltage Vdpm and the limiting battery voltage (that is, a constantvoltage protection parameter)) on a charging circuit by using thisembodiment of this application.

In an optional embodiment, after a charger is connected for charging,the processor may obtain the battery voltage in real time orperiodically, to adjust the related parameters of the charging circuitbased on the battery voltage, for example, the limiting battery voltageand the limiting power supply voltage Vdpm. Optionally, when detectingthat the battery is full charged, the processor may instruct to removethe charger, to end charging.

By implementing this embodiment of the present invention, the followingproblem with the prior art may be overcome: A charging chip is damagedbecause the limiting power supply voltage Vdpm cannot be updated intime, or a potential safety hazard such as battery explosion occursduring charging because a register is overwritten, or a charging speedcannot be flexibly adjusted, and the charging duration is excessivelylong because a limiting power supply voltage Vdpm is set once in theprior art. The charging duration can be shortened while charging safetyof the terminal device is ensured.

FIG. 5 is a schematic diagram of a linear charging circuit. The linearcharging circuit 500 may include a charging chip 502, a processor 504,and a battery 506. The charging chip 502 is electrically connected toboth the processor 504 and the battery 506. For the charging chip, theprocessor, and the battery, refer to related descriptions in theforegoing embodiments. Details are not described herein again.

In an optional embodiment, the switching charging circuit may furtherinclude a load (load), and the charging chip is electrically connectedto the load. Optionally, the linear charging circuit may further includean amplifier Q1, a resistor R, a charging interface, or anotherperipheral device. For example, in FIG. 5, the linear charging circuitfurther includes an amplifier Q1 and a resistor R, and the charging chipfurther includes a first port (shown as an Isense end in the figure). Abase of Q1 is electrically connected to a charging input end (VBUS) ofthe charging chip, a collector of Q1 is electrically connected to thebattery 506 by using the resistor R, the Isense end of the charging chipis electrically connected to one end of the collector of Q1 and theresistor R, a battery power supply end (VBAT) of the charging chip iselectrically connected to the other end of the battery and the resistorR, and an emitter of Q1 is electrically connected to the charginginterface.

In an optional embodiment, each port (or pin) of the charging chip has acorresponding voltage withstand range. If a port voltage exceeds thevoltage withstand range specified by the port, the charging chip isdamaged. As shown in FIG. 5, a battery of 4.4 V is used as an example,and the voltage withstand range of the Isense end of the charging chipis 0 to 4.5 V. Correspondingly, in a charging process, it needs to beensured that the Isense end of the charging chip cannot exceed 4.5 V, toeliminate the risk of over-voltage damage.

In an optional embodiment, when charging is performed by using thelinear charging circuit, the charging interface may be externallyconnected to a direct current (direct current, DC), for example, abattery is charged by using a charger, as specifically shown in FIG. 5.For related components used in the present invention, refer to relateddescriptions in the foregoing embodiments. Details are not describedherein again.

Based on the schematic diagram of the linear charging circuit shown inFIG. 5, FIG. 6 is a schematic structural diagram of a terminal deviceaccording to an embodiment of the present invention. The terminal devicemay include all or some of connected components of the linear chargingcircuit in the embodiment shown in FIG. 5. This is not limited in thepresent invention. FIG. 6 only shows that the terminal device includes acharging chip 502, a processor 504, and a battery 506. The followingdescribes specific embodiments related to these components.

The charging chip 502 is configured to convert a power supply voltageinto a battery voltage to charge the battery 506, where the power supplyvoltage is greater than a limiting power supply voltage, and the batteryvoltage is less than a limiting battery voltage.

The processor 504 is configured to: when a first condition is met,increase the limiting battery voltage, or decrease a charging currentwhile increasing the limiting battery voltage, where the first conditionincludes at least that the battery voltage is greater than a batteryvoltage threshold.

The processor 504 is further configured to: when a second condition ismet, decrease the limiting battery voltage, or increase the chargingcurrent while decreasing the limiting battery voltage, where the secondcondition includes at least that the battery voltage is less than thebattery voltage threshold.

The following describes some specific embodiments and optionalembodiments used in the present invention.

After the charger is connected to the terminal device for charging, theprocessor 504 may send a read instruction to the charging chip 502,where the read instruction is used to obtain a battery voltage, and thebattery voltage is a voltage at a battery power supply end of thecharging chip 502. Correspondingly, the charging chip receives the readinstruction, and reads the voltage at the battery power supply end basedon an instruction of the read instruction, that is, the battery voltagein this application.

Further, the processor 504 may adjust the limiting battery voltage (thatis, a constant voltage protection parameter) based on the batteryvoltage, or adjust both the limiting battery voltage and a chargingcurrent. For the limiting battery voltage and the charging current,refer to related descriptions in the foregoing embodiments. Details arenot described herein again.

During specific implementation, as shown in FIG. 5, the charging chipmay obtain the battery voltage and the charging current by detectingvoltages at two ends of the resistor R. Correspondingly, the processormay control/adjust a magnitude of the charging current by adjusting thebase of Q1 (also referred to as a control end). Specifically, when it isdetermined that the battery voltage is greater than the battery voltagethreshold, the processor 504 increases the limiting battery voltage, ordecreases the charging current while increasing the limiting batteryvoltage. On the contrary, when it is determined that the battery voltageis less than the battery voltage threshold, the processor 504 decreasesthe limiting battery voltage, or increases the charging current whiledecreasing the limiting battery voltage. The battery voltage thresholdmay be independently set on a user side or a terminal device side, andthis is not limited in the present invention.

A battery of 4.4 V is used as an example. As shown in FIG. 5, in acharging process, the processor may obtain a voltage (that is, thebattery voltage in this application) at the battery power supply end(VBAT) from the charging chip. Correspondingly, the processor maycorrespondingly adjust related parameters in the charging circuit basedon a threshold range in which the battery voltage is located. Forexample, when the battery voltage is less than or equal to a firstbattery voltage threshold (for example, 4.24 V), the processor maydecrease a maximum limiting voltage (that is, the limiting batteryvoltage or a constant voltage protection parameter) at the battery powersupply end to a first battery voltage (for example, 4.25 V), andoptionally may increase the charging current Ito a first chargingcurrent (for example, 1 A) by adjusting the collector of Q1. When thebattery voltage is greater than the first battery voltage threshold 4.24V and less than or equal to a second battery voltage threshold (forexample, 4.29 V), the processor may increase the limiting batteryvoltage to a second battery voltage (for example, 4.3 V), andoptionally, may decrease the charging current I to a second chargingcurrent (for example, 0.7 A). Correspondingly, when the battery voltageis greater than the second battery voltage threshold 4.29 V, theprocessor may increase the limiting battery voltage to a third batteryvoltage (for example, 4.35 V), and optionally, may decrease the chargingcurrent I to a third charging current (for example, 0.45 A). The firstbattery voltage is less than the second battery voltage, and the secondbattery voltage is less than the third battery voltage. The firstcharging current is greater than the second charging current, and thesecond charging current is greater than the third charging current.

In an optional embodiment, after a charger is connected for charging,the processor may obtain the battery voltage in real time orperiodically to adjust the related parameters in the charging circuitbased on the battery voltage, for example, the limiting battery voltageand the charging current. Optionally, when detecting that the battery isfull charged, the processor may instruct to remove the charger, to endcharging.

For content that is not described in this embodiment of the presentinvention, refer to related descriptions in the embodiments shown inFIG. 2A to FIG. 5. Details are not described herein again.

By implementing this embodiment of the present invention, the chargingduration can be shortened while charging safety of the terminal deviceis ensured.

Based on a same invention concept, the following describes a methodembodiment corresponding to the present invention. FIG. 7 is a schematicflowchart of a charging control method according to an embodiment of thepresent invention. The charging control method shown in FIG. 7 includesthe following implementation steps:

Step S702. The terminal device converts a power supply voltage into abattery voltage by using a charging chip, to charge the battery, wherethe power supply voltage is greater than a limiting power supplyvoltage, the battery voltage is less than a limiting battery voltage,the limiting power supply voltage is a minimum limiting voltage at acharging input end of the charging chip, and the limiting batteryvoltage is a maximum limiting voltage at a battery power supply end ofthe charging chip;

Step S704. When a first condition is met, the terminal device increasesboth the limiting power supply voltage and the limiting battery voltageby using a processor, or decreases a charging current while increasingthe limiting battery voltage by using the processor;

Step S706. When a second condition is met, the terminal device decreasesboth the limiting power supply voltage and the limiting battery voltageby using the processor, or increases, by using the processor, thecharging current while decreasing the limiting battery voltage, wherethe charging current is a current used to charge the battery, the firstcondition includes at least that the battery voltage is greater than abattery voltage threshold, and the second condition includes at leastthat the battery voltage is less than the battery voltage threshold.

In this application, to implement the charging of the terminal device, acharging circuit is disposed in the terminal device, where the chargingcircuit includes but is not limited to a switching charging circuit, a,linear charging circuit, and the like. The charging circuit indicationincludes a charging chip, a processor, a battery, and some othercomponents, for example, a load. For details, refer to relateddescriptions in the foregoing embodiments. Details are not describedherein again.

In an optional embodiment, the limiting power supply voltage is aminimum limiting voltage at a charging input end (VBUS) of the chargingchip, that is, the foregoing Vdpm. The limiting battery voltage is amaximum limiting voltage at a battery power supply end (VBAT) of thecharging chip, that is, the foregoing constant voltage protectionparameter. The power supply voltage refers to an actual voltage at thecharging input end of the charging chip. The battery voltage refers toan actual voltage at the battery power supply end of the charging chip.The charging current refers to a current used to charge the battery, forexample, a charging current passing through a resistor R that is shownin FIG. 5.

In an optional embodiment, when the charging circuit is a switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are decreased, the firstcondition may further include that a test voltage is less than a presetthreshold and/or a target quantity of times exceeds a preset quantity oftimes, where the target quantity of times refers to a quantity of timesthat the test voltage is less than the preset threshold.

Correspondingly, when the charging circuit is a switching chargingcircuit, to be specific, when both the limiting power supply voltage andthe limiting battery voltage are increased, the first condition mayfurther include that the test voltage is less than the preset thresholdand/or the target quantity of times exceeds the preset quantity oftimes, where the target quantity of times refers to a quantity of timesthat the test voltage is less than the preset threshold.

The test voltage is a voltage detected at a charging input end of thecharging chip. Specifically, the test voltage may be an actual voltagethat is detected at the charging input end after the charger isconnected to the terminal device.

Alternatively, the test voltage may be a test voltage detected at thecharging input end by using a test current. For details, refer torelated descriptions in the foregoing embodiment. Details are notdescribed herein again.

In an optional embodiment, when the charging circuit is the switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are decreased, the firstcondition further includes that the battery voltage is in a risingperiod.

In an optional embodiment, when the charging circuit is the switchingcharging circuit, to be specific, when both the limiting power supplyvoltage and the limiting battery voltage are decreased, the secondcondition further includes that the battery voltage is in the risingperiod, or the battery voltage is in a dropping period.

In an optional embodiment, in the switching charging circuit, when thesecond condition further includes that the battery voltage is in therising period, the battery voltage threshold is a first battery voltagethreshold; or when the second condition further includes that thebattery voltage is in the dropping period, the battery voltage thresholdis a second battery voltage threshold. The first battery voltagethreshold is greater than the second battery voltage threshold.

It should be noted that, in this application, step S704 and step S706may be performed in parallel, to be specific, the terminal device mayperform either of step S7104 and step S706. This not limited in thepresent invention.

For content that is not described in this embodiment of the presentinvention, refer to related descriptions in the embodiments described inFIG. 2A to FIG. 6. Details are not described herein again.

By implementing this embodiment of the present invention, the chargingduration of the terminal device can be shortened while charging safetyof the terminal device is ensured.

The foregoing mainly describes the solutions provided in the embodimentsof the present invention from a perspective of the terminal device. Itmay be understood that, to implement the foregoing functions, theterminal device includes corresponding hardware structures and/orsoftware modules for performing the functions. With reference to theunits and algorithm steps described in the embodiments disclosed in thepresent invention, embodiments of the present invention can beimplemented in a form of hardware or hardware and computer software.Whether a function is performed by hardware or hardware driven bycomputer software depends on particular applications and designconstraints of the technical solutions. A person skilled in the fieldmay use different methods to implement the described functions for eachparticular application, but it should not be considered that theimplementation falls beyond the scope of the technical solutions in thepresent invention.

In the embodiments of the present invention, a message processing devicemay be divided into function units based on the foregoing methodexamples. For example, each function unit may be obtained throughdivision based on a corresponding function, or two or more functions maybe integrated into one processing unit. The integrated unit may beimplemented in a form of hardware, or may be implemented in a form of asoftware function unit. It should be noted that, in this embodiment ofthe present invention, unit division is merely an example, and is merelya logical function division. In actual implementation, another divisionmanner may be used.

When an integrated unit is used, FIG. 8A is a possible schematicstructural diagram of the terminal device in the foregoing embodiments.The terminal device 800 includes a processing unit 802 and acommunications unit 803. The processing unit 802 is configured tocontrol and manage an action of the terminal device 800. For example,the processing unit 802 is configured to support the terminal device 800in performing S702, S704 and S706 in FIG. 7, and/or is configured toperform other steps of a technology described in this specification. Thecommunications unit 803 is configured to support communication betweenthe terminal device 800 and other terminal devices. For example, thecommunications unit 803 is configured to support the terminal device 800in performing data communication with the charger, and/or is configuredto perform other steps of the technology described in thisspecification. The terminal device 800 may further include a storageunit 801, configured to store program code and data of the terminaldevice 800.

The processing unit 802 may be a processor or a controller, such as acentral processing unit (Central Processing Unit, CPU), ageneral-purpose processor, a digital signal processor (Digital SignalProcessor, DSP), an application-specific integrated circuit(Application-Specific Integrated Circuit, ASIC), a field programmablegate array (Field Programmable Gate Array, FPGA), or anotherprogrammable logic device, a transistor logic device, a hardwarecomponent, or a combination thereof. The processing unit 802 mayimplement or execute various example logical blocks, modules, andcircuits described with reference to content disclosed in the presentinvention. Alternatively, the processor may be a combination forimplementing a computing function, for example, a combination of one ormore microprocessors, or a combination of the DSP and a microprocessor.The communications unit 803 may be a communications interface, atransceiver, a transceiver circuit, or the like. The communicationsinterface is a general name, and may include one or more interfaces, forexample, an interface between a message processing device and a terminaldevice. The storage unit 801 may be a memory.

In this application, the processing unit 802 may be the processor andthe charging chip in the foregoing embodiment shown in FIG. 2A, or maybe a charging chip in the foregoing embodiment shown in FIG. 2B, Thisnot limited in the present invention.

When the processing unit 802 is a processor, the communications unit 803is a communications interface, and the storage unit 801 is a memory, theterminal device in this embodiment of the present invention may be aterminal device shown in FIG. 8B.

As shown in FIG. 8B, the terminal device 810 includes: a processor 812,a communications interface 813, and a memory 811. Optionally, theterminal device 810 may further include a bus 814. The communicationsinterface 813, the processor 812, and the memory 811 are mutuallyconnected by using the bus 814. The bus 814 may be a peripheralcomponent interconnect (Peripheral Component Interconnect, PCI) bus, anextended industry standard architecture (Extended industry StandardArchitecture, EISA) bus, or the like. The bus 814 may be classified intoan address bus, a data bus, a control bus, and the like. For ease ofrepresentation, only one thick line is used to represent the bus in FIG.8B, but this does not mean that there is only one bus or only one typeof bus.

For specific implementation of the message processing device shown inFIG. 8A or FIG. 8B, refer to corresponding descriptions of theembodiments shown in FIG. 2A to FIG. 7. Details are not described hereinagain.

FIG. 9 is a schematic structural diagram of an apparatus according tothis application. As shown in FIG. 9, an apparatus 900 (for example, acharging chip) may include a processor 901 and one or more interfaces902 coupled to the processor 901.

The terminal processor 901 may be configured to read and execute acomputer readable instruction. During specific implementation, theprocessor 901 may mainly include a controller, an arithmetic unit, and aregister. The controller is mainly responsible for decoding aninstruction, and sends a control signal to an operation corresponding tothe instruction. The arithmetic unit is mainly responsible forperforming a fixed-point or floating-point arithmetic operation, a shiftoperation, a logic operation, and the like, and may also perform anaddress operation and an address conversion. The register is mainlyresponsible for saving a number of register operations temporarilystored during instruction execution, intermediate operation results, andthe like. During specific implementation, the hardware architecture ofthe processor 901 may be an application-specific integrated circuit(Application Specific Integrated Circuits, ASIC) architecture, an MIPSarchitecture, an ARM architecture, an NP architecture, or the like. Theprocessor 901 may be single-core or multi-core.

The interface 902 may be configured to input to-be-processed data to theprocessor 901, and may output a processing result of the processor 901.During specific implementation, the interface 902 may be a generalpurpose input output (General Purpose Input Output, GPIO) interface, andmay be connected to a plurality of peripheral devices (such as abattery, a display (LCD), a camera, and a radio frequency module). Theinterface 902 may further include a plurality of independent interfaces,for example, a battery interface, an Ethernet interface, an LCDinterface, and a camera interface. These interfaces are separatelyresponsible for communication between different peripheral devices andthe processor 901.

In this application, the processor 901 may be configured to invoke, fromthe memory, an implementation program of the charging control methodprovided in this application on a terminal device side, and execute aninstruction included in the program. The interface 902 may be configuredto output an execution result of the processor 901. In this application,the interface 902 may be specifically configured to output a batteryvoltage of the processor 901. For the charging control method providedin this application, refer to related descriptions in the foregoingembodiments, Details are not described herein again.

It should be noted that functions respectively corresponding to theprocessor 901 and the interface 902 may be implemented by hardwaredesign, may be implemented by software design, or may be implemented ina combination of software and hardware. This is not limited herein.

Methods or algorithm steps described in combination with the contentdisclosed in this embodiment of the present invention may be implementedby hardware, or may be implemented by a processor by executing asoftware instruction. The software instruction may include acorresponding software module. The software module may be stored in arandom access memory (Random Access Memory, RAM), a flash memory, a readonly memory (Read Only Memory, ROM), an erasable programmable read onlymemory (Erasable Programmable ROM, EPROM), an electrically erasableprogrammable read only memory (Electrically EPROM, EEPROM), a register,a hard disk, a removable hard disk, a compact disc read-only memory(CD-ROM), or any other form of storage medium well-known in the art. Anexample storage medium is coupled to a processor, so that the processorcan read information from the storage medium or write information intothe storage medium. Certainly, the storage medium may be a component ofthe processor. The processor and the storage medium may be located inthe ASIC. In addition, the ASIC may be located in a network device.Certainly, the processor and the storage medium may exist in the networkdevice as discrete components.

A person of ordinary skill in the art may understand that all or some ofthe processes of the methods in the embodiments may be implemented by acomputer program instructing related hardware. The program may be storedin a computer readable storage medium. When the program runs, theprocesses of the methods in the embodiments are performed. The foregoingstorage medium includes any medium that can store program code, such asa ROM, a RAM, a magnetic disk, or an optical disc.

What is claimed is:
 1. A charging device, comprising: a charging chipcomprising a charging input end and a battery power supply end, whereinthe charging chip is configured to convert a power supply voltage into abattery voltage to charge a battery, wherein the power supply voltage isgreater than a limiting power supply voltage, wherein the batteryvoltage is less than a limiting battery voltage, wherein the limitingpower supply voltage is a minimum limiting voltage at the charging inputend, and wherein the limiting battery voltage is a maximum limitingvoltage at the battery power supply end; and a processor coupled to thecharging chip and configured to: increase both the limiting power supplyvoltage and the limiting battery voltage when a first condition is met,wherein the first condition comprises the battery voltage being greaterthan a battery voltage threshold; and decrease both the limiting powersupply voltage and the limiting battery voltage when a second conditionis met, wherein the second condition comprises the battery voltage beingless than the battery voltage threshold.
 2. The charging device of claim1, wherein the first condition further comprises that a test voltage atthe charging input end is less than a preset threshold a preset quantityof times.
 3. The charging device of claim 1, wherein the secondcondition further comprises that a test voltage at the charging inputend is less than a preset threshold a preset quantity of times.
 4. Thecharging device of claim 1, wherein the first condition furthercomprises that the battery voltage is in a rising period.
 5. Thecharging device of claim 1, wherein the second condition furthercomprises that the battery voltage is in a rising period, or in adropping period.
 6. The charging device of claim 5, wherein the batteryvoltage threshold is a first battery voltage threshold when the batteryvoltage is in the rising period, wherein the battery voltage thresholdis a second battery voltage threshold when the battery voltage is in thedropping period, and wherein the first battery voltage threshold isgreater than the second battery voltage threshold.
 7. A charging controlmethod, comprising: converting a power supply voltage into a batteryvoltage to charge a battery, wherein the power supply voltage is greaterthan a limiting power supply voltage, wherein the battery voltage isless than a limiting battery voltage, wherein the limiting power supplyvoltage is a minimum limiting voltage at a charging input end of acharging chip, and wherein the limiting battery voltage is a maximumlimiting voltage at a battery power supply end of the charging chip;increasing the limiting power supply voltage and the limiting batteryvoltage when a first condition is met, wherein the first conditioncomprises the battery voltage being greater than a battery voltagethreshold; and decreasing the limiting power supply voltage and thelimiting battery voltage when a second condition is met, wherein thesecond condition comprises the battery voltage being less than thebattery voltage threshold.
 8. The charging control method of claim 7,wherein the first condition further comprises that a test voltage at thecharging input end of the charging chip is less than a preset thresholda preset quantity of times.
 9. The charging control method of claim 7,wherein the second condition further comprises that a test voltage atthe charging input end of the charging chip is less than a presetthreshold a preset quantity of times.
 10. The charging control method ofclaim 7, wherein the first condition further comprises that the batteryvoltage is in a rising period.
 11. The charging control method of claim7, wherein the second condition further comprises that the batteryvoltage is either in a rising period, or in a dropping period.
 12. Thecharging control method of claim 11, wherein the battery voltagethreshold is a first battery voltage threshold when the battery voltageis in the rising period, wherein the battery voltage threshold is asecond battery voltage threshold when the battery voltage is in thedropping period, and wherein the first battery voltage threshold isgreater than the second battery voltage threshold.
 13. The chargingcontrol method of claim 7, wherein the limiting battery voltage is aconstant voltage protection parameter.
 14. A computer program productcomprising computer-executable instructions for storage on anon-transitory computer-readable medium that, when executed by aprocessor, cause an apparatus to: convert a power supply voltage into abattery voltage to charge a battery, wherein the power supply voltage isgreater than a limiting power supply voltage, wherein the batteryvoltage is less than a limiting battery voltage, wherein the limitingpower supply voltage is a minimum limiting voltage at a charging inputend of a charging chip, and wherein the limiting battery voltage is amaximum limiting voltage at a battery power supply end of the chargingchip; increase the limiting power supply voltage and the limitingbattery voltage when a first condition is met, wherein the firstcondition comprises the battery voltage being greater than a batteryvoltage threshold; and decrease the limiting power supply voltage andthe limiting battery voltage when a second condition is met, wherein thesecond condition comprises the battery voltage being less than thebattery voltage threshold.
 15. The computer program product of claim 14,wherein the first condition further comprises that a test voltage at thecharging input end of the charging chip is less than a preset thresholda preset quantity of times.
 16. The computer program product of claim14, wherein the second condition further comprises that a test voltageat the charging input end of the charging chip is less than a presetthreshold a preset quantity of times.
 17. The computer program productof claim 14, wherein the first condition further comprises that thebattery voltage is in a rising period.
 18. The computer program productof claim 14, wherein the second condition further comprises that thebattery voltage is either in a rising period, or in a dropping period.19. The computer program product of claim 18, wherein the batteryvoltage threshold is a first battery voltage threshold when the batteryvoltage is in the rising period, wherein the battery voltage thresholdis a second battery voltage threshold when the battery voltage is in thedropping period, and wherein the first battery voltage threshold isgreater than the second battery voltage threshold.
 20. The computerprogram product of claim 14, wherein the limiting battery voltage is aconstant voltage protection parameter.